package com.toptech.downloadmanager;

import android.os.Parcel;
import android.os.Parcelable;

import org.litepal.crud.DataSupport;

/**
 * Created by zhengshaorui on 2017/3/2.
 */

public class TaskInfo extends DataSupport  implements  Parcelable{

    private long id;  //文件id,这里必须为long，且字段为id,用于获取数据自增id
    private String filename;  //文件名
    private String fileurl;   //文件url
    private int fileprogress;  //文件的下载进度
    private String filedownsize; //文件已经下载的大小，比如已经下载了12.12M
    private String filesize;  // 文件的大小
    private int threadcount; //文件的要求的线程个数
    private int priority;    //文件的优先级


    protected TaskInfo(Parcel in) {
        id = in.readLong();
        filename = in.readString();
        fileurl = in.readString();
        fileprogress = in.readInt();
        filedownsize = in.readString();
        filesize = in.readString();
        threadcount = in.readInt();
        priority = in.readInt();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(id);
        dest.writeString(filename);
        dest.writeString(fileurl);
        dest.writeInt(fileprogress);
        dest.writeString(filedownsize);
        dest.writeString(filesize);
        dest.writeInt(threadcount);
        dest.writeInt(priority);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<TaskInfo> CREATOR = new Creator<TaskInfo>() {
        @Override
        public TaskInfo createFromParcel(Parcel in) {
            return new TaskInfo(in);
        }

        @Override
        public TaskInfo[] newArray(int size) {
            return new TaskInfo[size];
        }
    };

    public TaskInfo() {
    }

    public TaskInfo(long id, String filename, String fileurl, int fileprogress,
                    String filedownsize, String filesize, int threadcount, int priority) {
        this.id = id;
        this.filename = filename;
        this.fileurl = fileurl;
        this.fileprogress = fileprogress;
        this.filedownsize = filedownsize;
        this.filesize = filesize;
        this.threadcount = threadcount;
        this.priority = priority;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getFilename() {
        return filename;
    }

    public void setFilename(String filename) {
        this.filename = filename;
    }

    public String getFileurl() {
        return fileurl;
    }

    public void setFileurl(String fileurl) {
        this.fileurl = fileurl;
    }

    public int getFileprogress() {
        return fileprogress;
    }

    public void setFileprogress(int fileprogress) {
        this.fileprogress = fileprogress;
    }

    public String getFiledownsize() {
        return filedownsize;
    }

    public void setFiledownsize(String filedownsize) {
        this.filedownsize = filedownsize;
    }

    public String getFilesize() {
        return filesize;
    }

    public void setFilesize(String filesize) {
        this.filesize = filesize;
    }

    public int getThreadcount() {
        return threadcount;
    }

    public void setThreadcount(int threadcount) {
        this.threadcount = threadcount;
    }

    public int getPriority() {
        return priority;
    }

    public void setPriority(int priority) {
        this.priority = priority;
    }

    @Override
    public String toString() {
        return "TaskInfo{" +
                "id=" + id +
                ", filename='" + filename + '\'' +
                ", fileurl='" + fileurl + '\'' +
                ", fileprogress=" + fileprogress +
                ", filedownsize='" + filedownsize + '\'' +
                ", filesize='" + filesize + '\'' +
                ", threadcount=" + threadcount +
                ", priority=" + priority +
                '}';
    }
}
